package com.gitee.dolt.core.exception.code;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author LYH
 */
@Getter
@AllArgsConstructor
public enum ExceptionCode implements BaseExceptionCode {

    OK(0, "成功"),
    SYSTEM_BUSY(-1, "系统繁忙，请稍后再试"),
    SQL_EX(-4, "运行SQL出现异常"),
    BASE_VALID_PARAM(-9, "统一参数验证异常"),
    OPERATION_EX(-10, "操作异常"),
    CAPTCHA_ERROR(-12, "验证码校验失败"),
    DISABLED_API(-13, "api被禁用"),

    DECRYPT_ERROR(-20, "数据加解密异常"),

    BAD_REQUEST(400, "错误的请求"),
    UNAUTHORIZED(401, "未经授权"),
    NOT_FOUND(404, "没有找到资源"),
    METHOD_NOT_ALLOWED(405, "不支持当前请求类型"),

    INTERNAL_SERVER_ERROR(500, "内部服务错误"),

    JWT_BASIC_INVALID(40000, "无效的基本身份验证令牌"),
    JWT_TOKEN_EXPIRED(40001, "会话超时，请重新登录"),
    JWT_SIGNATURE(40002, "不合法的token，请认真比对 token 的签名"),
    JWT_ILLEGAL_ARGUMENT(40003, "缺少token参数"),
    JWT_GEN_TOKEN_FAIL(40004, "生成token失败"),
    JWT_PARSER_TOKEN_FAIL(40005, "解析用户身份错误，请重新登录"),
    JWT_USER_INVALID(40006, "用户名或密码错误"),
    JWT_USER_ENABLED(40007, "用户已经被禁用"),


    ;

    private int code;
    private String msg;

    public ExceptionCode build(String message, Object... args) {
        this.msg = StrUtil.format(message, args);
        return this;
    }
}
